<template>
	<u-popup v-model="show" mode="center" :mask-close-able="false" border-radius="20">
		<view class="popVue">
			<view class="title text-center">支付密码验证</view>
			<input type="password" placeholder="请输入支付密码" v-model="tradePwd"/>
			<view class="flex-between margin50">
				<view class="cancel" @click="cancel()">取消</view>
				<view class="confirm" @click="confirm()">确认</view>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false
			},
		},
		data(){
			return {
				tradePwd: ""
			}
		},
		methods: {
			cancel(){
				this.tradePwd = ""
				this.$emit("cancel")
			},
			async confirm(){
				if(!this.tradePwd) return this.$u.toast("请输入支付密码")
				const res = await this.$request("/app-api/member/user/valid-pay-password", "POST", {
					payPassword: this.tradePwd
				})
				if(res.code===0) {
					console.log(res)
					if(!res.data) return this.$u.toast("支付密码错误")
					let tradePwd = this.tradePwd
					this.$emit("orderFun", tradePwd)
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.popVue {
		width: 690rpx;
		padding: 30rpx 40rpx 50rpx;
		.title {
			color: #333;
			font-size: 32rpx;
			font-weight: 600;
		} 
		input {
			width: 100%;
			height: 88rpx;
			border: 1rpx solid #f5f5f5;
			display: block;
			box-sizing: border-box;
			border-radius: 12rpx;
			text-align: center;
			color: #333;
			font-size: 28rpx;
			margin-top: 30rpx;
		}
		.cancel, .confirm {
			width: 280rpx;
			height: 82rpx;
			text-align: center;
			line-height: 82rpx;
			font-weight: 600;
			border-radius: 20rpx;
			font-size: 30rpx;
		}
		.cancel {
			border: 1rpx solid #1CC289;
			color: #1CC289;
		}
		.confirm {
			background: linear-gradient(to right, #1CC289, #60A5FA);
			color: #fff;
		}
	}
</style>